<?php

class Shop extends MY_Controller {
	
	function __constructor()
	{
		parent::MY_Controller();
		
		$this->load->library('parser');
		//$this->load->scaffolding('feed');
	}
	
	function index()
	{
		// body data
		
		$content = $this->load->view('forms/nhaphang', $forms, true);
		$data["body"]["content"] = $content;
		
		/*
		//$data["body"]["fruits"] = array("apple", "cherry", "melon");
		//$data["body"]["path"] = $this->config->item("base_url");
		*/
		
		// head data
		$data["head"]['heading'] = 'Menu links';
		$data["head"]['menu_links'] = array(
			array('name'=>'Home', 'url'=>''),
			array('name'=>'Import', 'url'=>'import')
		);
		
		// load from views > partials > header.php
		$this->template->set_partial('header', 'partials/header', $data["head"]);		
		$this->template->title('My iShop :: Home');
		
		// load from views > body.php
		$this->template->build('body', $data["body"]);
	}
	
	function facebook()
	{
		$adata = array();
		
		$this->load->library('myutils');
		
		$data["title"] = "FB wall";
		$data["content"] = "Our Facebook Wall";
		//$rs = $this->db->get('feed');
		$rs = $this->db->query('SELECT * FROM feed LIMIT 0,5');
		
		foreach ($rs->result() as $row){
			if ($row->created_time > 0)
				$row->created_time = $this->myutils->ago($row->created_time);
			else
				$row->created_time = "";
			$adata[] = $row;
		}
		 
		$data["feeds"] = $adata;
		
		$config['base_url'] = 'http://myfacebook.com/index.php/fb/facebook/';
		$config['total_rows'] = '50';
		$config['per_page'] = '5';

		$this->load->library('pagination');
		$this->pagination->initialize($config); 
		
		$data["paging"] = $this->pagination->create_links();
		
		$this->load->view('facebook_view', $data);
	}
	
	function hihihi()
	{
		echo "Test";
	}
}